home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Griffith 0.9.8 / griffith-0.9.8-win32.exe / {app} / lib / plugins / movie / PluginMovieDVDPalace.py < prev    next >
Text File  |  2008-11-17  |  6KB  |  209 lines

  1. # -*- coding: UTF-8 -*-
  2.  
  3. __revision__ = '$Id: PluginMovieDVDPalace.py 1040 2008-11-15 21:13:49Z mikej06 $'
  4.  
  5. # Copyright (c) 2006-2007
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU Library General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  20.  
  21. # You may use and distribute this software under the terms of the
  22. # GNU General Public License, version 2 or later
  23.  
  24. import gutils
  25. import movie
  26. import string
  27. import re
  28.  
  29. plugin_name = "DVD-Palace"
  30. plugin_description = "DVD-Onlinemagazin mit DVD-Datenbank"
  31. plugin_url = "www.dvd-palace.de"
  32. plugin_language = _("German")
  33. plugin_author = "Michael Jahn"
  34. plugin_author_email = "<mikej06@hotmail.com>"
  35. plugin_version = "1.0"
  36.  
  37. class Plugin(movie.Movie):
  38.  
  39.     def __init__(self, id):
  40.         self.encode   = 'iso-8859-1'
  41.         self.movie_id = id
  42.         self.url      = 'http://www.dvd-palace.de/dvd-datenbank/' + self.movie_id
  43.  
  44.     def get_image(self):
  45.         self.image_url = gutils.trim(self.page, 'src="/showcover.php?', '"')
  46.         if self.image_url <> '':
  47.             self.image_url = 'http://www.dvd-palace.de/showcover.php?' + self.image_url
  48.  
  49.     def get_o_title(self):
  50.         self.o_title = gutils.trim(self.page, 'Originaltitel', '</b>')
  51.         if self.o_title == '':
  52.             self.o_title = gutils.trim(self.page, '<TITLE>', ' - DVD Details')
  53.  
  54.     def get_title(self):
  55.         self.title = gutils.trim(self.page, '<TITLE>', ' - DVD Details')
  56.  
  57.     def get_director(self):
  58.         self.director = gutils.trim(self.page, 'Regisseur(e)', '</TR>')
  59.  
  60.     def get_plot(self):
  61.         self.plot = re.sub(
  62.             '[0-9 ]+Views', '',
  63.             re.sub(
  64.                 '[┬û]', '-',
  65.                 re.sub(
  66.                     '[\x93┬ä]', '"', self.regextrim(self.page, 'showcover.php[^>]*>', '</td>'))))
  67.  
  68.     def get_year(self):
  69.         self.year = gutils.after(gutils.trim(gutils.trim(self.page, 'Originaltitel', '</TR>'), '(', ')'), ' ')
  70.  
  71.     def get_runtime(self):
  72.         self.runtime = gutils.strip_tags(string.replace(gutils.trim(self.page, 'Laufzeit', ' min'), 'ca. ', ''))
  73.  
  74.     def get_genre(self):
  75.         self.genre = string.replace(string.replace(gutils.trim(self.page, 'Genre(s)', '</TR>'), ' ', ''), '<br>', ', ')
  76.  
  77.     def get_cast(self):
  78.         self.cast = string.replace(
  79.             re.sub('<em>[^<]*</em>', ' ',
  80.                 re.sub(',[ ]*', '\n',
  81.                     gutils.trim(self.page, 'Darsteller / Sprecher', '</TR>')
  82.                 )
  83.             ),
  84.             '\n ', '\n')
  85.  
  86.     def get_classification(self):
  87.         self.classification = string.replace(gutils.trim(self.page, 'Altersfreigabe (FSK)', '</TR>'), ' ', '')
  88.  
  89.     def get_studio(self):
  90.         self.studio = string.replace(string.replace(gutils.trim(self.page, 'Label', '</td>'), ' ', ''), ':', '')
  91.  
  92.     def get_o_site(self):
  93.         self.o_site = ""
  94.  
  95.     def get_site(self):
  96.         self.site = self.url
  97.  
  98.     def get_trailer(self):
  99.         self.trailer = ''
  100.  
  101.     def get_country(self):
  102.         self.country = gutils.before(gutils.trim(gutils.trim(self.page, 'Originaltitel', '</TR>'), '(', ')'), ' ')
  103.  
  104.     def get_rating(self):
  105.         self.rating = "0"
  106.  
  107.     def get_notes(self):
  108.         self.notes = ""
  109.         tmp_notes = re.sub('^[ \t]+', '',
  110.             gutils.strip_tags(
  111.             re.sub('(<br>|<br />)', '\r\n',
  112.             re.sub('[\r\n]+', '',
  113.             re.sub('[ \t][ \t\r\n]+', ' ',
  114.             gutils.trim(self.page, 'Bildformat(e)', '</TR>')))))
  115.         )
  116.         if (tmp_notes != ""):
  117.             self.notes = self.notes + "Bildformat(e):\n" + tmp_notes + "\n"
  118.         tmp_notes = re.sub('^[ \t]+', '',
  119.             gutils.strip_tags(
  120.             re.sub('(<br>|<br />)', '\r\n',
  121.             re.sub('[\r\n]+', '',
  122.             re.sub('[ \t][ \t\r\n]+', ' ',
  123.             gutils.trim(self.page, 'Tonformat(e)', '</TR>')))))
  124.         )
  125.         if (tmp_notes != ""):
  126.             self.notes = self.notes + "Tonformat(e):\n" + tmp_notes + "\n\n"
  127.         tmp_notes = re.sub('^[ \t]+', '',
  128.             gutils.strip_tags(
  129.             re.sub('(<br>|<br />)', '\r\n',
  130.             re.sub('[\r\n]+', '',
  131.             re.sub('[ \t][ \t\r\n]+', ' ',
  132.             gutils.trim(self.page, 'Untertitel', '</TR>')))))
  133.         )
  134.         if (tmp_notes != ""):
  135.             self.notes = self.notes + "Untertitel:" + tmp_notes + "\n\n"
  136.             
  137.     def regextrim(self,text,key1,key2):
  138.         obj = re.search(key1, text)
  139.         if obj is None:
  140.             return ''
  141.         else:
  142.             p1 = obj.end()
  143.         obj = re.search(key2, text[p1:])
  144.         if obj is None:
  145.             return ''
  146.         else:
  147.             p2 = p1 + obj.end()
  148.         return text[p1:p2]
  149.  
  150. class SearchPlugin(movie.SearchMovie):
  151.  
  152.     def __init__(self):
  153.         self.original_url_search   = "http://www.dvd-palace.de/dvddatabase/dbsearch.php?action=1&suchbegriff="
  154.         self.translated_url_search = "http://www.dvd-palace.de/dvddatabase/dbsearch.php?action=1&suchbegriff="
  155.         self.encode='iso-8859-1'
  156.  
  157.     def search(self,parent_window):
  158.         self.open_search(parent_window)
  159.         tmp_pagemovie = self.page
  160.         #
  161.         # try to get all result pages (not so nice, but it works)
  162.         #
  163.         tmp_pagecount = gutils.trim(tmp_pagemovie, 'Seiten (<b>', '</b>)')
  164.         try:
  165.             tmp_pagecountint = int(tmp_pagecount)
  166.         except:
  167.             tmp_pagecountint = 1
  168.         tmp_pagecountintcurrent = 1
  169.         while (tmp_pagecountint > tmp_pagecountintcurrent and tmp_pagecountintcurrent < 5):
  170.             self.url = "http://www.dvd-palace.de/dvddatabase/dbsearch.php?action=1&start=" + str(tmp_pagecountintcurrent * 20) + "&suchbegriff="
  171.             self.open_search(parent_window)
  172.             tmp_pagemovie = tmp_pagemovie + self.page
  173.             tmp_pagecountintcurrent = tmp_pagecountintcurrent + 1
  174.         self.page = tmp_pagemovie
  175.         return self.page
  176.  
  177.     def get_searches(self):
  178.         elements1 = re.split(' <a title="[^"]+" href="/dvd-datenbank/', self.page)
  179.         elements1[0] = None
  180.         for element in elements1:
  181.             if element <> None:
  182.                 self.ids.append(gutils.before(element,'"'))
  183.                 self.titles.append(
  184.                     gutils.trim(element, '>', '</a>') +
  185.                     gutils.strip_tags(
  186.                         ' (' +
  187.                         re.sub('[ \t\n][ \t\n]+', ' ',
  188.                         string.replace(
  189.                         string.replace(
  190.                             self.regextrim(element, '<div [^>]*>', '</div>'),
  191.                             '<br>', ' - '),
  192.                             ' ', ''))
  193.                         + ')'
  194.                     )
  195.                 )
  196.             
  197.     def regextrim(self,text,key1,key2):
  198.         obj = re.search(key1, text)
  199.         if obj is None:
  200.             return ''
  201.         else:
  202.             p1 = obj.end()
  203.         obj = re.search(key2, text[p1:])
  204.         if obj is None:
  205.             return ''
  206.         else:
  207.             p2 = p1 + obj.end()
  208.         return text[p1:p2]
  209.